package com.redis.notify;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPubSub;

public class NotifyDemo {

	public static void main(String[] args) {

		Jedis jedis = new Jedis("192.168.109.131", 6379);

		JedisPubSub pubSub = new JedisPubSub() {
			@Override
			public void onPSubscribe(String pattern, int subscribedChannels) {
				System.out.println(pattern + ":" + subscribedChannels);
			}

			@Override
			public void onMessage(String channel, String message) {
				System.out.println("channel:" + channel + ",message:" + message);
			}
		};

		Runnable task = () -> {
			System.out.println("start listen");
			jedis.psubscribe(pubSub, "*");

		};

		Thread thread = new Thread(task);

		thread.start();

	}
}
